
package edu.faytechcc.csc251.db;

import java.sql.*;

/**
 *
 * @author kent
 */
public class BuildMTGcardDB {
    public static void main(String[] args) 
            throws Exception
    {
        final String DB_URL = 
                "jdbc:derby:MTGCardDB;create=true";
        
        try
        {
            //Create a connection to the database.
            Connection conn = DriverManager.getConnection(DB_URL);
            
            //Create a Statement object
            Statement stmt = conn.createStatement();
            
            //Create the card table
            System.out.println("Creating the card table...");
            stmt.execute("CREATE TABLE Card (" +
                    "Name CHAR(50), " +
                    "SetName CHAR(50), " +
                    "ID CHAR(10) NOT NULL PRIMARY KEY, " +
                    "Type CHAR(50), " +
                    "Power CHAR(5), " +
                    "Toughness CHAR(5), " +
                    "Manacost CHAR(50), " +
                    "ConvertedManacost CHAR(10), " +
                    "Color CHAR(10), " +
                    "Rarity CHAR(10), " +
                    "Ability CLOB(700)," +
                    "Image VARCHAR(254))");
            
            //Close the resources
            stmt.close();
            conn.close();
            System.out.println("Done");
        }
        catch(Exception ex)
        {
            System.out.println("ERROR: " + ex.getMessage());
        }
    }
}
